//
//  GoodsDetailTopView.m
//  Youhuiju
//
//  Created by 余尚飞 on 16/8/2.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "GoodsDetailTopView.h"

@interface GoodsDetailTopView ()


@property(nonatomic,strong)UIButton *backButton;//返回
@property(nonatomic,strong)UIView *lineView;
@end

@implementation GoodsDetailTopView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self creatView];
    }
    return self;
}
-(void)creatView
{
    self.backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.backButton.tag = 0;
    [self.backButton setBackgroundImage:LoadImage(@"back") forState:UIControlStateNormal];
    [self.backButton addTarget:self action:@selector(backButtonClickedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.backButton];
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(12 * FitW);
        make.top.equalTo(self.mas_top).offset(13 * FitH);
        make.size.mas_offset(CGSizeMake(19 * FitW, 19 * FitH));
    }];
    
    
    self.goodsButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.goodsButton.tag = 1;
//    self.goodsButton.reversesTitleShadowWhenHighlighted = NO;
    [self.goodsButton setTitle:@"商品" forState:UIControlStateNormal];
    self.goodsButton.titleLabel.font = [UIFont systemFontOfSize:14 * FitH];
    self.goodsButton.tintColor = [UIColor blackColor];
    [self.goodsButton addTarget:self action:@selector(backButtonClickedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.goodsButton];
    [self.goodsButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.backButton.mas_right).offset(83 * FitW);
        make.centerY.equalTo(self.mas_centerY);
        make.size.mas_offset(CGSizeMake(36 * FitW, 18 * FitH));
;
    }];
//    self.goodsButton.backgroundColor = [UIColor redColor];
    
    self.detailButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.detailButton.tag = 2;
    [self.detailButton setTitle:@"详情" forState:UIControlStateNormal];
    self.detailButton.titleLabel.font = [UIFont systemFontOfSize:14 * FitH];
    self.detailButton.tintColor = [UIColor blackColor];
    [self.detailButton addTarget:self action:@selector(backButtonClickedAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.detailButton];
    [self.detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodsButton.mas_right).offset(75 * FitW);
        make.centerY.equalTo(self.mas_centerY);
        make.size.mas_offset(CGSizeMake(36 * FitW, 18 * FitH));
    }];
    
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor colorWithHexString:@"eeeeee"];
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.bottom.equalTo(self.mas_bottom);
        make.height.mas_offset(1 * FitH);
    }];
    
    self.scrollLine = [[UIImageView alloc]init];
    self.scrollLine.image = LoadImage(@"scrollLine");
    [self addSubview:self.scrollLine];
    [self.scrollLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodsButton.mas_left).priorityLow();
        make.bottom.equalTo(self.lineView.mas_top);
        make.size.mas_equalTo(CGSizeMake(35 * FitW, 2 * FitH));
    }];
    
    
}

-(void)backButtonClickedAction:(UIButton *)sender
{
    if (self.backButtonClickedHandler)
    {
        self.backButtonClickedHandler(sender.tag);
    }
}
@end
